{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Save Preprocessing Reports"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This example can be referenced by [citing the package](https://neuropsychology.github.io/NeuroKit/cite_us.html).\n",
    "\n",
    "Reports are currently a **beta** feature (help us improve it!) only available for PPG signals. \n",
    "\n",
    "You can generate a report via the `report` argument in the processing function."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": [
     "remove-input"
    ]
   },
   "outputs": [],
   "source": [
    "# Note: this cell is hidden using the \"remove-input\" tag\n",
    "import matplotlib.pyplot as plt\n",
    "# Make bigger images\n",
    "plt.rcParams['figure.figsize'] = [15, 5]  \n",
    "plt.rcParams['font.size']= 14"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": [
     "skip-execution"
    ]
   },
   "outputs": [],
   "source": [
    "# import neurokit2 as nk\n",
    "\n",
    "# Simulate PPG signal\n",
    "# signal = nk.ppg_simulate(duration=30, sampling_rate=200, heart_rate=60)\n",
    "\n",
    "# Process signal and save report\n",
    "# df, info = nk.ppg_process(ppg_signal = signal, report = \"ppg_report.html\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "tags": [
     "remove-input"
    ]
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The raw signal, sampled at 1000 Hz, was preprocessed using a bandpass filter ([0.5 - 8 Hz], Butterworth 3rd order; following Elgendi et al., 2013).\n",
      "\n",
      "The peak detection was carried out using the method described in Elgendi et al. (2013).\n",
      "\n",
      "|   PPG_Rate_Mean |   PPG_Rate_SD |\n",
      "|----------------:|--------------:|\n",
      "|         93.7041 |       23.5124 |\n",
      "\n",
      "References\n",
      "- Elgendi M, Norton I, Brearley M, Abbott D, Schuurmans D (2013) Systolic Peak Detection in Acceleration Photoplethysmograms Measured from Emergency Responders in Tropical Conditions. PLoS ONE 8(10): e76585. doi:10.1371/journal.pone.0076585.\n"
     ]
    }
   ],
   "source": [
    "# Note: this cell is hidden using the \"remove-input\" tag\n",
    "# import neurokit2 as nk\n",
    "\n",
    "# Simulate PPG signal\n",
    "# signal = nk.ppg_simulate(duration=30, sampling_rate=200, heart_rate=60)\n",
    "\n",
    "# Process signal and save report\n",
    "# df, info = nk.ppg_process(ppg_signal = signal, report = \"text\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "It also saves a `html` file (see example here) with interactive plots.\n",
    "\n",
    "![](ppg_report.png)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.9.7 64-bit",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  },
  "vscode": {
   "interpreter": {
    "hash": "11938c6bc6919ae2720b4d5011047913343b08a43b18698fd82dedb0d4417594"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
